package com.zx.BookSeaReader.ui.home.bookcommunity;

import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.zx.BookSeaReader.R;
import com.zx.BookSeaReader.greendao.entity.BookLabelBean;
import com.zx.BookSeaReader.greendao.entity.BookListBean;
import com.zx.BookSeaReader.ui.base.adapter.ViewHolderImpl;
import com.zx.BookSeaReader.util.Constant;
import com.zx.BookSeaReader.util.StringUtils;


public class BookListHolder extends ViewHolderImpl<BookListBean> {

    private ImageView ivListImg;
    private TextView tvTitle;
    private TextView tvDesc;
    private TextView tvAuthor;
    private TextView tvTime;
    private TextView tvLoveCount;
    private TextView tvBookCount;



    @Override
    public void initView() {
        ivListImg = findById(R.id.iv_book_list_img);
        tvTitle = findById(R.id.tv_list_title);
        tvAuthor = findById(R.id.tv_username);
        tvTime = findById(R.id.tv_time);
        tvDesc = findById(R.id.tv_info);
        tvLoveCount = findById(R.id.tv_like_count);
        tvBookCount = findById(R.id.tv_book_count);
    }

    @Override
    public void onBind(BookListBean data, int pos) {
        Glide.with(getContext())
                .load(data.getCover())
                .placeholder(R.mipmap.no_image)
                .error(R.mipmap.no_image)
                .into(ivListImg);
        tvTitle.setText(data.getTitle());
        tvAuthor.setText(data.getUsername());
        tvAuthor.setText(data.getUsername());
        tvBookCount.setText(" | 共"+data.getBookCount()+"本书");
        tvDesc.setText(data.getDesc());
        tvLoveCount.setText(data.getCollectorCount()+"");
        tvTime.setText(StringUtils.dateConvert(data.getCreateTime(), Constant.FORMAT_BOOK_DATE));

    }

    @Override
    protected int getItemLayoutId() {
        return R.layout.item_book_list_info;
    }
}
